#include <stdio.h>
#include <assert.h>

int plus(int x, int y) 
{
    return x + y;
}

int minus(int x, int y) 
{
    return x - y;
}

int multiply(int x, int y) 
{
    return x * y;
}

int divide(int x, int y)
{
    assert(y != 0);

    return x / y;
}

int main(int argc, char *argv[])
{
    int x, y;
    int option;

    printf("please input option(0=plus 1=minux 2=multiply 3=divide):");
    scanf("%d", &option);
    printf("please input x, y:");
    scanf("%d%d", &x, &y);

    int (*calc_arr[4])(int, int) = {plus, minus, multiply, divide};

    switch(option) 
    {
        case 0:
            printf("%d + %d = %d\n", x, y, (*calc_arr[option])(x, y));
            break;
        case 1:
            printf("%d - %d = %d\n", x, y, (*calc_arr[option])(x, y));
            break;
        case 2:
            printf("%d * %d = %d\n", x, y, (*calc_arr[option])(x, y));
            break;
        case 3:
            printf("%d / %d = %d\n", x, y, (*calc_arr[option])(x, y));
            break;
        default:
            printf("error option: %d.\n", option);
    }


    return 0;
}
